<template>
    <view class="ti">
        <view class="top">
            <uni-row>
                <uni-col :span="6" :offset="1">
                    <text class="top-text">选择入园日期</text>
                </uni-col>
                <uni-col :span="4" :offset="13">
                    <text class="top-time">2024.09</text>
                </uni-col>
            </uni-row>
        </view>
        <view class="box1">
            <view class="button-group1">
                <button
                    v-for="(item, index) in buttons"
                    :key="index"
                    class="botton"
                    :class="{ 'no-border': true, 'active-button': selectedIndex === index,   }"
                    :disabled="item.open === '闭馆'||item.people ==='已约满'"
                    @click="selectButton(item,index)"
                >
                    <view
                        class="s-t1"
                        :class="{ 'no-border': true,'active-text':selectedIndex === index,'closed-button1': item.open === '闭馆'||item.people ==='已约满'}"
                    >{{ item.week }}</view>
                    <view
                        class="s-t2"
                        :class="{ 'no-border': true,'active-text':selectedIndex === index,'closed-button2': item.open === '闭馆'||item.people ==='已约满'}"
                    >{{ item.date }}</view>
                    <view
                        class="open-text"
                    >{{ item.open }}</view>
                    <view
                        class="open-pe"
                    >{{ item.people }}</view>
                </button>
            </view>
            </view>
        <view class="t2">
            <text class="top-text">选择入院时段</text>
        </view>
        <view class="box2">
            <view class="button-group2">
                <button
                    v-for="(itema, index2) in buttons2"
                    :key="index2"
                    class="botton2"
                    :class="{ 'no-border': true, 'active-button2': selectedIndex2 === index2 }"
                    :disabled="itema.stat === '已约满'"
                    @click="selectButton2(index2)"
                >
                    <view class="s-t3"
                          :class="{ 'no-border': true,'active-text':selectedIndex2 === index2,}"
                    >{{ itema.time }}|{{ itema.stat }}</view>
                </button>
            </view>
        </view>
        <view>
            <navigator url="../yy/teamyy" hover-class="navigator-hover" >
                <button class="btn-area" ><text class="btn">时段确定</text></button>
            </navigator>
        </view>
    </view>
</template>

<script setup>
import {
    ref
} from "vue"


const buttons = [
    {
        week: "周六",
        date: "01"

    },
    {
        week: "周日",
        date: "02"
    },
    {
        week: '周一',
        date: "07",
        open:"闭馆"
    },
    {
        week: "周二",
        date: "04"
    },
    {
        week: "周三",
        date: "05"
    },
    {
        week: "周四",
        date: "06"
    },
    {
        week: "周五",
        date: "07",
        people:"已约满"
    },
    {
        week: "周六",
        date: "08",
        people:"已约满"

    },
    {
        week: "周日",
        date: "09",
        people:"已约满"
    },
    {
        week: '周一',
        date: "10",
        open:"闭馆"
    },
    {
        week: "周二",
        date: "11"
    },
    {
        week: "周三",
        date: "12"
    },
    {
        week: "周四",
        date: "13"
    },
    {
        week: "周五",
        date: "14",
        people:"已约满"
    }
];
const buttons2= [
    {
        time:"09:00-11:00",
        stat:"已约满"
    },
    {
        time:"11:00-13:30",
        stat:"已约满"
    },
    {
        time:"13:30-16:00",
        stat:"余 4"
    },
]

const selectedIndex = ref(null); // 第一组按钮的选中状态

const selectButton = (item, index) => {
    if (item.open !== '闭馆'||item.people !=='已约满') {
        selectedIndex.value = index;
    }
};
const selectedIndex2 = ref(null); // 第一组按钮的选中状态

const selectButton2 = (index2) => {
    selectedIndex2.value = index2; // 更新第一组按钮的选中状态
};

</script>

<style scoped>
.open-text{
    width: 16px;
    height: 11px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    font-size: 8px;
    color: #A4A4A4;
    letter-spacing: 0;
    position: relative;
    top:5px;
}
.botton{
    margin-top: 6px;

}
.botton2{
    width: 160px;
    height: 27px;
    background: #F5F5F5;
    border-radius: 2px;
    flex-basis: calc(50% - 10px); /* 每个按钮占50%，并减去左右边距 */
    margin: 5px;
}
.top-text {
    width: 90px;
    height: 21px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #000000;
    letter-spacing: 0;
    /*top: 16px;*/
    /*left: 12px;*/
    /*position: relative;*/
}

.top-time {
    width: 59px;
    height: 21px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #000000;
    letter-spacing: 0;
    /*top: 16px;*/
    /*right: 11px;*/
    /*position: relative;*/

}

.top {
    position: relative;
    top: 16px;

}

.ti {
    width: 375px;
    height: 722px;
    background: #F3F5F9;
}
.t2{
    position: relative;
    top:40px;
    left:16px;
}

.box1 {
    width: 351px;
    height: 166px;
    background: #FFFFFF;
    border-radius: 12px;
    top: 30px;
    left: 12px;
    position: relative;
}
.box2 {
    width: 351px;
    height: 166px;
    background: #FFFFFF;
    border-radius: 12px;
    top: 50px;
    left: 12px;
    position: relative;
}
.s1{
    width: 16px;
    height: 21px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #000000;
    letter-spacing: 0;
}
.b1{
    width: 42px;
    height: 64px;
    background: #F5F5F5;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 0;
    margin-inside: 1;
    flex-direction:column;
}
.s-t1{
    width: 20px;
    height: 14px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    font-size: 10px;
    color: #000000;
    letter-spacing: 0;
    position: relative;
    right:2px;
}
.s-t2{
    width: 16px;
    height: 21px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #000000;
    letter-spacing: 0;
}
.s-t3{
    width: 139px;
    height: 20px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    font-size: 14px;
    color: #6B6B6B;
    letter-spacing: 0;
    bottom:6px;
    position: relative;
    right: 5px;
}
.button-group1 {
    position: relative;
    top:14px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-right: 16px;
    margin-top: 10px;
    left:10px;
}
.button-group2{
    position: relative;
    top:10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.active-button2 {
    width: 160px;
    height: 27px;
    background: #8DCB6D;
    border-radius: 2px;
}
button {
    width: 42px;
    height: 64px;
    background: #F5F5F5;
    border-radius: 4px;
}

.active-button {
    width: 42px;
    height: 64px;
    background: #8DCB6D;
    border-radius: 4px;
    color: white;
}
.closed-button1{
    width: 20px;
    height: 14px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 10px;
    color: #A4A4A4;
    letter-spacing: 0;
}
.closed-button2{
    width: 18px;
    height: 21px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 15px;
    color: #A4A4A4;
    letter-spacing: 0;
}
.btn{
    width: 68px;
    height: 24px;
    font-family: PingFangSC-Medium;
    font-weight: 500;
    font-size: 17px;
    color: #FFFFFF;
    letter-spacing: 0;
}
.btn-area{
    width: 351px;
    height: 45px;
    background: #8DCB6D;
    border-radius: 25px;
    align-content: center;
    top:200px;
}
.active-text{
    color: white;
}
.open-pe{
    width: 24px;
    height: 11px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    font-size: 8px;
    color: #A4A4A4;
    letter-spacing: 0;
    position: relative;
    bottom:6px;
    right:3px;
}
</style>